This Week's Sponsor:

Collections Database

A Powerful Database with iCloud Sync


The Ultimate Introduction to Applescript: Part 1

Applescript, that amazing resource many Mac users ignore because they think it’s too complex. Guys, Applescript is an amazing tool to get things done automatically, though I recognize many of you just don’t want to get started because you don’t have the right motivation, or you just don’t know enough about it. I wrote a post which collected the best examples of Applescript but still, there wasn’t a real introduction.

That’s why I asked my friend Jesse from iScript Netcast to get started on a posts series about Applescript. There will be 3 parts, where Jesse will outline the pros and cons of Applescript, together with some sample scripts and tips for beginners.You can also get in touch with iScript Netcast on Twitter here.

Enjoy!

What is AppleScript?

Ever since the first personal computer, people have looked for ways to make their computers do things automatically. We buy apps all the time to make our lives easier. However, sometimes those apps aren’t quite enough,sometimes we need more functionality or need more automation than that provided by the application. Apple began in version 7 of their operating system to ship a tool that the average end-users could learn and use to their advantage, a tool called AppleScript.

AppleScript is an english-based interpreted programming language. This means that you do not have to be a programmer to learn how to write AppleScript. If you can speak english and write sentences similar to…

Tell application “iTunes” to play

…then you can write AppleScript. The “interpreted language” simply means that Mac OS simply executes your commands on the fly. This makes AppleScript very easy to troubleshoot since you can watch as it interacts with the system and other applications.

Applescript Editor Snow Leopard

Applescript Editor Snow Leopard

Why Use AppleScript?

AppleScript is designed to make your life easier by allowing every Mac owner to automate tasks they perform every day. We are creatures of habit, we all have some sort of routine we go through every time we turn on our computer at home, work or on the road. AppleScript is a great way to make those mundane and often times annoying tasks go away… Forever.

Another reason to make AppleScript your automation language of choice is because of its tight integration with the applications you already know and love in OS X. It can help improve them or can make them work together. Many of the actions which make the iLife suite (iTunes, iPhoto, iMovie, and iDVD) work so well together are just simple AppleScripts.

How do I Begin?

Anytime you want to learn something new the best thing to do is have a reason for learning it. Learning a programming language, like AppleScript, is no different. Think of something you do on your computer day-in and day-out that is a repetitive task. It doesn’t have to be anything intense or even spectacular. Simple renaming of files or organization of iTunes tracks will do!

iTunes 9

iTunes 9

Next, set out to accomplish writing your script. Don’t let yourself get frustrated by initial failure. AppleScript is an easy language learn but the concepts of programming can often be difficult. Having a book can often help get you started on the concepts of application development as well as the syntax of AppleScript. An older but excellent resource is O’Reilly’s book entitled “AppleScript: The Definitive Guide”.

While it is a few years out of date it still will get you on the right track.

What’s Next?

This concludes part one of your introduction to AppleScript. Next time I will include some sample scriptlets from some of my first scripts as well as more ideas on what you could script to start automating your computer and your life with AppleScript.

Happy Scripting!

Unlock More with Club MacStories

Founded in 2015, Club MacStories has delivered exclusive content every week for over six years.

In that time, members have enjoyed nearly 400 weekly and monthly newsletters packed with more of your favorite MacStories writing as well as Club-only podcasts, eBooks, discounts on apps, icons, and services. Join today, and you’ll get everything new that we publish every week, plus access to our entire archive of back issues and downloadable perks.

The Club expanded in 2021 with Club MacStories+ and Club Premier. Club MacStories+ members enjoy even more exclusive stories, a vibrant Discord community, a rotating roster of app discounts, and more. And, with Club Premier, you get everything we offer at every Club level plus an extended, ad-free version of our podcast AppStories that is delivered early each week in high-bitrate audio.

Choose the Club plan that’s right for you:

  • Club MacStories: Weekly and monthly newsletters via email and the web that are brimming with app collections, tips, automation workflows, longform writing, a Club-only podcast, periodic giveaways, and more;
  • Club MacStories+: Everything that Club MacStories offers, plus exclusive content like Federico’s Automation Academy and John’s Macintosh Desktop Experience, a powerful web app for searching and exploring over 6 years of content and creating custom RSS feeds of Club content, an active Discord community, and a rotating collection of discounts, and more;
  • Club Premier: Everything in from our other plans and AppStories+, an extended version of our flagship podcast that’s delivered early, ad-free, and in high-bitrate audio.